home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Installation Tools & Overlays 2002 November
/
SGI IRIX Installation Tools & Overlays 2002 November - Disc 4.iso
/
dist
/
infosearch.idb
/
usr
/
lib
/
infosearch
/
bin
/
man2html.z
/
man2html
Wrap
Text File
|
2002-10-15
|
3KB
|
118 lines
#!/usr/bin/perl
#
# Copyright 1996-2002, Silicon Graphics, Inc.
# All Rights Reserved.
#
# This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
# the contents of this file may not be disclosed to third parties, copied or
# duplicated in any form, in whole or in part, without the prior written
# permission of Silicon Graphics, Inc.
#
# RESTRICTED RIGHTS LEGEND:
# Use, duplication or disclosure by the Government is subject to restrictions
# as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
# and Computer Software clause at DFARS 252.227-7013, and/or in similar or
# successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
# rights reserved under the Copyright Laws of the United States.
#
# --------
# man2html
# --------
# filter man pages into HTML
#
# Usage:
# man2html [-r <root>] [-h <highlight_str>] /<standard_path>/<file>
# man2html [-r <root>] [-h <highlight_str>] <section> <manpage>
#
# requires perl5 and man2html.pl
#
$| = 1;
use strict;
# globals
#
package InfoSearch;
$InfoSearch::COLLECTION = $ENV{'COLLECTION'};
$InfoSearch::_TR = $ENV{'TOOLROOT'};
$InfoSearch::_WEB = ($ENV{'REQUEST_METHOD'} ne '' ? 1 : 0);
$InfoSearch::_DB = 'man';
require 'man2html.pl';
&main(@ARGV);
exit(0);
#######################################################################
#
# void main()
#
#######################################################################
sub main {
my(@argv) = @_;
unless ($argv[0]) {
print "man2html: no arguments" if (${InfoSearch::_WEB} == 0);
return;
}
my($fname, $man_root, $srch_str) = '';
my($i) = 0;
while($i < (@argv + 0)) {
if ($argv[$i] eq "-h") {
splice(@argv, $i, 1);
if( $argv[$i] ne '' ) {
$srch_str = $argv[$i];
splice(@argv, $i, 1);
}
} elsif ($argv[$i] eq "-r") {
splice(@argv, $i, 1);
if( $argv[$i] ne '' ) {
$man_root = $argv[$i];
splice(@argv, $i, 1);
}
} else {
$i++;
}
}
# take whatever is left
#
$fname = join(' ', @argv);
# Set the path for security and taint checking.
#
$ENV{'PATH'} = "${InfoSearch::_TR}/usr/sbin:" .
"${InfoSearch::_TR}/usr/bin:" .
"${InfoSearch::_TR}/bin:/usr/sbin:/usr/bin:/bin";
# check (again!)
#
my($OK_CHARS) = "-a-zA-Z0-9_.*\@,:;()\ \+\/";
$fname =~ s/[^$OK_CHARS]//go;
if( $fname =~ /\.\./ || $fname =~ /^\/etc/ || $fname =~ /\&/
||
$fname =~ /\;/ || $fname =~ /\|/ || $fname =~ /\,/
||
$fname =~ /\>/ || $fname =~ /\</ ) {
print "man2html: Illegal document access" if (${InfoSearch::_WEB} == 0);
return;
}
&man2html($man_root, $fname, $srch_str);
return;
}